package com.bookstore.pojo;

import java.io.Serializable;

/**
 * 购物项
 */
public class CartItem implements Serializable {
    //当前购买图书
    private Book book;
    //数量
    private Integer count;
    //总金额
    private Double totalPrice;

    public CartItem() {
    }

    public CartItem(Book book, Integer count, Double totalPrice) {
        this.book = book;
        this.count = count;
        this.totalPrice = totalPrice;
    }

    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    //计算总金额
    public Double getTotalPrice() {
        totalPrice=getBook().getPrice()*getCount();
        return  totalPrice;
    }

    @Override
    public String toString() {
        return "CartItem{" +
                "book=" + book +
                ", count=" + count +
                ", totalPrice=" + totalPrice +
                '}';
    }
}
